home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / Clipboard.java < prev    next >
Text File  |  1998-09-22  |  2KB  |  78 lines

  1. /*
  2.  * @(#)Clipboard.java    1.6 98/07/01
  3.  *
  4.  * Copyright 1995-1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  * 
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.awt.datatransfer;
  16.  
  17. /**
  18.  * A class which implements a mechanism to transfer data using 
  19.  * cut/copy/paste operations.
  20.  *
  21.  * @version     1.6, 07/01/98
  22.  * @author    Amy Fowler
  23.  */
  24. public class Clipboard {
  25.  
  26.     String name;
  27.  
  28.     protected ClipboardOwner owner;
  29.     protected Transferable contents;
  30.  
  31.     /**
  32.      * Creates a clipboard object.
  33.      */
  34.     public Clipboard(String name) {
  35.         this.name = name;
  36.     }
  37.  
  38.     /**
  39.      * Returns the name of this clipboard object.
  40.      */
  41.     public String getName() {
  42.         return name;
  43.     }
  44.  
  45.     /**
  46.      * Sets the current contents of the clipboard to the specified
  47.      * transferable object and registers the specified clipboard owner
  48.      * as the owner of the new contents.  If there is an existing owner 
  49.      * registered, that owner is notified that it no longer holds ownership
  50.      * of the clipboard contents.
  51.      * @param content the transferable object representing the clipboard content
  52.      * @param owner the object which owns the clipboard content
  53.      */
  54.     public synchronized void setContents(Transferable contents, ClipboardOwner owner) {
  55.     if (this.owner != null && this.owner != owner) {
  56.         this.owner.lostOwnership(this, this.contents);
  57.     }
  58.     this.owner = owner;
  59.     this.contents = contents;
  60.     }
  61.  
  62.     /**
  63.      * Returns a transferable object representing the current contents
  64.      * of the clipboard.  If the clipboard currently has no contents,
  65.      * it returns null.
  66.      * @param requestor the object requesting the clip data
  67.      * @return the current transferable object on the clipboard
  68.      */
  69.     public synchronized Transferable getContents(Object requestor) {
  70.         return contents;
  71.     }
  72.  
  73. }
  74.  
  75.     
  76.  
  77.     
  78.